var e = getApp();

Page({
    data: {
        is_check: 1,
        userinfo: {},
        isAndroid:true,
    },
    onLoad:function(){
        const systemInfo = wx.getSystemInfoSync()
        const isIOS = systemInfo.platform === 'ios'
        if (isIOS) {
          this.setData({
            isAndroid:false
          })
        } else {
            this.setData({
                isAndroid:true
            })
        }
    },
    onShow: function() {
        this.getUserInfo();
    },
    getUserInfo: function() {
        var t = this;
        e.util.request({
            url: "/user/getInfo"
        }).then(function(e) {
            t.setData({
                userinfo: e.data,
                is_check: e.data.is_check
            });
        });
    },
    getUserProfile: function() {
        var t = this;
        wx.getUserProfile({
            desc: "使用微信登录"
        }).then(function(n) {
            n.errMsg.indexOf("fail") > 0 ? e.util.message("授权失败", "error") : e.util.request({
                url: "/user/setUserAvatar",
                data: {
                    encryptedData: n.encryptedData,
                    iv: n.iv
                }
            }).then(function(e) {
                t.getUserInfo();
            });
        }).catch(function() {});
    },
    getUserPhone: function(t) {
        var n = this;
        if ("getPhoneNumber:ok" != t.detail.errMsg) {
            var r = t.detail.errMsg;
            return -1 !== r.indexOf("user deny") && (r = "已取消授权"), void e.util.message(r, "error");
        }
        e.util.request({
            url: "/user/setUserPhone",
            data: {
                encryptedData: t.detail.encryptedData,
                iv: t.detail.iv
            }
        }).then(function(e) {
            n.getUserInfo();
        });
    },
    linkto: function(e) {
        var t = e.currentTarget.dataset.url;
        wx.navigateTo({
            url: t
        });
    },
    toPayVip: function() {
        wx.navigateTo({
            url: "/pages/pay/vip"
        });
    },
    toTask: function() {
        wx.switchTab({
            url: "/pages/task/index"
        });
    },
    toInputNickname: function() {
        wx.navigateTo({
            url: "/pages/user/nickname"
        });
    }
});